Skip to content

Add chapter on floating point data#12

Merged
LiamPattinson merged 7 commits intomainfrom
floating_point
Feb 16, 2026
Merged

Add chapter on floating point data#12
LiamPattinson merged 7 commits intomainfrom
floating_point

Conversation

@LiamPattinson
Copy link
Collaborator

@LiamPattinson LiamPattinson commented Feb 14, 2026

Resolves #7
Resolves #9

Changes data structures chapter to one about handling floating point numbers.

  • Introduces absolute/relative tolerances
  • Mentions the built-in math.isclose, then goes straight to NumPy routines (skips np.isclose for simplicity)
  • Adds a callout stating that direct equality checks are a bad idea in an earlier chapter
  • Adds $\pi$ estimation routine as an example.
  • Removes all content on comparing lists/dicts. Could add this earlier in the course, but I don't think it needs to be a focus, especially given the numpy routines can be used for lists.
  • Strips all pandas material for simplicity, replaces it with a simple callout so interested people know it exists.

Additionally includes some edits to the setup doc.

@github-actions
Copy link

github-actions bot commented Feb 14, 2026

Thank you!

Thank you for your pull request 😃

🤖 This automated message can help you check the rendered files in your submission for clarity. If you have any questions, please feel free to open an issue in {sandpaper}.

If you have files that automatically render output (e.g. R Markdown), then you should check for the following:

  • 🎯 correct output
  • 🖼️ correct figures
  • ❓ new warnings
  • ‼️ new errors

Rendered Changes

🔍 Inspect the changes: https://github.com/ResearchCodingClub/python-testing-for-research/compare/md-outputs..md-outputs-PR-12

The following changes were observed in the rendered markdown documents:

 04-unit-tests-best-practices.md                    |  70 +--
 06-floating-point-data.md (new)                    | 282 ++++++++++++
 06-testing-data-structures.md (gone)               | 471 ---------------------
 .../advanced/advanced_calculator.py (new)          |   6 +
 .../advanced/test_advanced_calculator.py (new)     |   7 +
 files/06-floating-point-data/calculator.py (new)   |  15 +
 files/06-floating-point-data/estimate_pi.py (new)  |  10 +
 files/06-floating-point-data/scripts.py (new)      |  21 +
 .../statistics/stats.py (new)                      |  34 ++
 .../statistics/test_stats.py (new)                 |  82 ++++
 .../test_calculator.py (new)                       |  29 ++
 .../test_estimate_pi.py (new)                      |  12 +
 .../test_floating_point.py (new)                   |  12 +
 files/06-floating-point-data/test_numpy.py (new)   |  27 ++
 files/07-fixtures/estimate_pi.py (new)             |  10 +
 files/07-fixtures/statistics/stats.py              | 104 -----
 files/07-fixtures/statistics/test_stats.py         |  54 ---
 files/07-fixtures/test_estimate_pi.py (new)        |  12 +
 files/07-fixtures/test_numpy.py (new)              |  27 ++
 files/08-parametrization/estimate_pi.py (new)      |  10 +
 files/08-parametrization/statistics/stats.py       | 104 -----
 files/08-parametrization/statistics/test_stats.py  |  54 ---
 files/08-parametrization/test_estimate_pi.py (new) |  12 +
 files/08-parametrization/test_numpy.py (new)       |  27 ++
 files/09-testing-output-files/estimate_pi.py (new) |  10 +
 files/09-testing-output-files/statistics/stats.py  | 104 -----
 .../statistics/test_stats.py                       |  55 ---
 .../test_estimate_pi.py (new)                      |  12 +
 files/09-testing-output-files/test_numpy.py (new)  |  27 ++
 md5sum.txt                                         |   8 +-
 setup.md                                           |  45 +-
 31 files changed, 760 insertions(+), 993 deletions(-)
What does this mean?

If you have source files that require output and figures to be generated (e.g. R Markdown), then it is important to make sure the generated figures and output are reproducible.

This output provides a way for you to inspect the output in a diff-friendly manner so that it's easy to see the changes that occur due to new software versions or randomisation.

⏱️ Updated at 2026-02-16 15:39:34 +0000

github-actions bot pushed a commit that referenced this pull request Feb 14, 2026
LiamPattinson and others added 3 commits February 16, 2026 15:32
Co-authored-by: Ava <avadean7@hotmail.com>
Co-authored-by: Ava <avadean7@hotmail.com>
Co-authored-by: Ava <avadean7@hotmail.com>
github-actions bot pushed a commit that referenced this pull request Feb 16, 2026
@LiamPattinson
Copy link
Collaborator Author

Thanks for the comments @avadean! Ironically I hadn't tested the code in the lesson to see if it would actually run.

github-actions bot pushed a commit that referenced this pull request Feb 16, 2026
@LiamPattinson
Copy link
Collaborator Author

@avadean Do you think this is ready to merge?

@avadean
Copy link
Collaborator

avadean commented Feb 16, 2026

Yes looks great to me! @LiamPattinson

@LiamPattinson LiamPattinson merged commit de7a5aa into main Feb 16, 2026
3 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 16, 2026
Auto-generated via `{sandpaper}`
Source  : de7a5aa
Branch  : main
Author  : Liam Pattinson <LiamPattinson@users.noreply.github.com>
Time    : 2026-02-16 17:40:31 +0000
Message : Merge pull request #12 from ResearchCodingClub/floating_point

Add chapter on floating point data
github-actions bot pushed a commit that referenced this pull request Feb 16, 2026
Auto-generated via `{sandpaper}`
Source  : fe7b28e
Branch  : md-outputs
Author  : GitHub Actions <actions@github.com>
Time    : 2026-02-16 17:42:00 +0000
Message : markdown source builds

Auto-generated via `{sandpaper}`
Source  : de7a5aa
Branch  : main
Author  : Liam Pattinson <LiamPattinson@users.noreply.github.com>
Time    : 2026-02-16 17:40:31 +0000
Message : Merge pull request #12 from ResearchCodingClub/floating_point

Add chapter on floating point data
@LiamPattinson LiamPattinson deleted the floating_point branch February 16, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flag that direct comparisons to floating point numbers is bad Replace data structures lesson with floating point comparisons

2 participants